home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / etc / init.d / waitnfs.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2006-10-06  |  1.9 KB  |  100 lines

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          waitnfs
  4. # Required-Start:    $network $local_fs
  5. # Required-Stop:
  6. # Default-Start:     S
  7. # Default-Stop:
  8. # Short-Description: Wait for network file systems to be mounted
  9. # Description:       Network file systems are mounted in the background when
  10. #                    interfaces are brought up; this script waits for them
  11. #                    to be mounted before carrying on.
  12. ### END INIT INFO
  13.  
  14. [ -f /etc/default/rcS ] && . /etc/default/rcS
  15. . /lib/lsb/init-functions
  16.  
  17. do_start() {
  18.     [ -f /etc/fstab ] || return
  19.     #
  20.     # Read through fstab line by line. If it is NFS, set the flag
  21.     # for mounting NFS file systems. If any NFS partition is found
  22.     # then wait around for it.
  23.     #
  24.  
  25.     exec 9<&0 </etc/fstab
  26.  
  27.     waitnfs=
  28.     while read DEV MTPT FSTYPE OPTS REST
  29.     do
  30.         case "$DEV" in
  31.           ""|\#*)
  32.             continue
  33.             ;;
  34.         esac
  35.         case "$OPTS" in
  36.           noauto|*,noauto|noauto,*|*,noauto,*)
  37.             continue
  38.             ;;
  39.         esac
  40.         case "$FSTYPE" in
  41.           nfs|nfs4|smbfs|cifs|coda|ncp|ncpfs|ocfs2|gfs)
  42.             ;;
  43.           *)
  44.             continue
  45.             ;;
  46.         esac
  47.         case "$MTPT" in
  48.           /usr/local|/usr/local/*)
  49.             ;;
  50.           /usr|/usr/*)
  51.             waitnfs="$waitnfs $MTPT"
  52.             ;;
  53.           /var|/var/*)
  54.             waitnfs="$waitnfs $MTPT"
  55.             ;;
  56.         esac
  57.     done
  58.  
  59.     exec 0<&9 9<&-
  60.  
  61.     # Wait for each path, the timeout is for all of them as that's
  62.     # really the maximum time we have to wait anyway
  63.     TIMEOUT=900
  64.     for mountpt in $waitnfs; do
  65.         log_action_begin_msg "Waiting for $mountpt"
  66.  
  67.         while ! mountpoint -q $mountpt; do
  68.             sleep 0.1
  69.  
  70.             TIMEOUT=$(( $TIMEOUT - 1 ))
  71.             if [ $TIMEOUT -le 0 ]; then
  72.                 log_action_end_msg 1
  73.                 break
  74.             fi
  75.         done
  76.  
  77.         if [ $TIMEOUT -gt 0 ]; then
  78.             log_action_end_msg 0
  79.         fi
  80.     done
  81. }
  82.  
  83. case "$1" in
  84.     start)
  85.         do_start
  86.         ;;
  87.     restart|reload|force-reload)
  88.         echo "Error: argument '$1' not supported" >&2
  89.         exit 3
  90.         ;;
  91.     stop)
  92.         ;;
  93.     *)
  94.         echo "Usage: $0 start|stop" >&2
  95.         exit 3
  96.         ;;
  97. esac
  98.  
  99. : exit 0
  100.